package stream.Demo05;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Author Miku
 * @Create 2021/4/29 14:54
 * 使用字节缓冲流写入文件
 */
public class Test {
    public static void main(String[] args) throws IOException {
        //1.创建字节输出缓冲流
        FileOutputStream fos = new FileOutputStream("e:\\buffer.txt");
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        //2.写入文件
        for (int i = 0; i<10; i++) {
            bos.write("hello world\n".getBytes());
        }
        bos.flush();
        //3.关闭
        bos.close();
    }
}
